package org.jiang.springbootdemo.demos.web.listener;

import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.boot.context.event.ApplicationStartedEvent;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

@Component
public class MyApplicationListener {

    //监听单个事件
    @EventListener
    public void listenerApplicationStarted(ApplicationStartedEvent event) {
        System.out.println("应用启动完成");
    }

    //监听多个事件
    @EventListener({ApplicationReadyEvent.class, ApplicationStartedEvent.class})
    public void listenerApplication() {
        System.out.println("监听到了多个事件");
    }
}

